def p(n):
     for i in range (2, n):
         if n %i == 0:
          return False
     return True
a = input().split()
a = ''.join(a)
a = a.replace('zero', '0').replace('one', '1').replace('two', '2').replace('three','3').replace('four','4').replace('five', '5').replace('six', '6').replace('seven', '7').replace('eight', '8').replace('nine', '9')
a=int(a)
if a >= 100 and a <= 999:
         prost = []
         for i in range(2, 1000):
            if p(i):
                prost.append(i)
         mn = 10000
         k = 0
         for i in prost:
             if abs (i - a) < mn:
                 mn = abs(i - a)
                 k= i
         print(k)
else:
    print("Wrong input")
